#ifndef HELLO_HELLO_H
#define HELLO_HELLO_H

#include "clientinfo.h"

#define HELLO_HEADER_SIZE 4

/**
 * if data corrupted, 0 is returned, list does not change.
 *
 * \param list	   return argument
 * \param data	   data to read from
 * \param data_len data length
 * \return         number of interests read
 *
 */
uint32_t read_hello(HASHTBL *hash,
                    char * data, 
                    size_t data_len);

/**
 * Serializes interests from list into buf in following format:
 * | 4 bytes (NetworkEndian) | null-separated string list |
 * 
 * \param buf 	  output buffer
 * \param buf_len buffer length
 * \param list	  input list of interests 
 * \return 	  number of bytes written, 0 means error
 */
size_t write_hello(char ** buf,
                   HASHTBL *hash);

void    write_header(char * dat, uint32_t n);

/**
 * Prints hello package in nice, human-readable format
 */
void print_argz(char * buf, size_t buf_len);

size_t to_argz(char ** argz, HASHTBL *hash);
#endif // HELLO_HELLO_H
